package routines;

import java.math.BigDecimal;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Index;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

/**
 * @author Миха
 *
 */
@Entity
@Table(name = "purchase_objects",indexes = {@Index(columnList = "lot_id", name = "idx_purchase_objects_lot_id")})
public class PurchaseObject extends Print{
	private Long objectId;
	/**
	 * Название
	 */
	private String name;
	/**
	 * ОКПД
	 */
	private String okpd;

	/**
	 * Количество
	 */
	private Double quantity;
	
	/**
	 * Общее количество
	 */
	private Double totalSum;
	
	private Lot lot;
	
	public PurchaseObject(){};

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO, generator = "seq_objects_gen")
	@SequenceGenerator(name = "seq_objects_gen", sequenceName = "seq_purchase_objects")
	@Column(name = "object_id")
	public Long getObjectId() {
		return objectId;
	}

	public void setObjectId(Long object_id) {
		this.objectId = object_id;
	}

	@Column(columnDefinition = "TEXT")
	public String getName() {
		return name;
	}

	/**
	 * @param name Название объекта закупки
	 */
	public void setName(String name) {
		this.name = name;
	}

	@Column(columnDefinition = "TEXT")
	public String getOkpd() {
		return okpd;
	}

	public void setOkpd(String okpd) {
		this.okpd = okpd;
	}

	public Double getQuantity() {
		return quantity;
	}

	public void setQuantity(Double quantity) {
		this.quantity = quantity;
	}

	public Double getTotalSum() {
		return totalSum;
	}

	public void setTotalSum(Double totalSum) {
		this.totalSum = totalSum;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "lot_id", nullable = false)
	public Lot getLot() {
		return lot;
	}

	public void setLot(Lot lot) {
		this.lot = lot;
	}


}
